package org.foundation.jala.jamerzip.view;

import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

@SuppressWarnings("serial")
public class ZipMenuBar extends JMenuBar{

    
    
    public ZipMenuBar() {
        JMenu file = new JMenu("File");
        JMenuItem newZip = new JMenuItem("New");
        JMenuItem open = new JMenuItem("Open");
        JMenuItem close = new JMenuItem("Close");
        file.add(newZip);
        file.add(new JPopupMenu.Separator());
        file.add(open);
        file.add(close);
        
        this.add(file);
        
        JMenu edit = new JMenu("Options");
        JMenuItem properties = new JMenuItem("Properties");
        JMenuItem extract = new JMenuItem("Extract");
        
        edit.add(properties);
        edit.add(extract);
        this.add(edit);  
    }
    
    public void addActionToItem(int menu, int menuItem,ActionListener action){
        try{
            this.getMenu(menu).getItem(menuItem).addActionListener(action);
        }catch(Exception e)
        {
            Logger.getLogger("UI").log(Level.WARNING,e.getMessage());
        }
    }
}
